package com.android.citynetworkpin.fragment.member;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.android.citynetworkpin.R;
import com.android.citynetworkpin.activity.BaseObject;
import com.android.citynetworkpin.adapt.GridDetaillikeAdapt;
import com.android.citynetworkpin.fragment.BaseLazyFragment;
import com.android.citynetworkpin.model.MainTabData;
import com.android.citynetworkpin.model.data;
import com.android.citynetworkpin.model.dataCallback;
import com.android.citynetworkpin.model.group.MainList;
import com.android.citynetworkpin.model.group.MainListCallback;
import com.android.citynetworkpin.model.member.OrderDetailData;
import com.android.citynetworkpin.model.member.OrderDetailDataCallback;
import com.android.citynetworkpin.utils.ConstantsUrl;
import com.android.citynetworkpin.utils.HttpUtils;
import com.android.citynetworkpin.utils.LoginState;
import com.android.citynetworkpin.utils.MyLog;
import com.android.citynetworkpin.utils.ObjectUtils;
import com.android.citynetworkpin.view.MyGridView;
import com.android.citynetworkpin.view.dialog.MainMsg;
import com.mcxtzhang.nestlistview.NestFullListView;
import com.mcxtzhang.nestlistview.NestFullListViewAdapter;
import com.mcxtzhang.nestlistview.NestFullViewHolder;

import java.util.ArrayList;
import java.util.HashMap;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.Call;


/**
 * 订单详情页
 */
public class Fragment_Mine_Detail extends BaseLazyFragment {


    @BindView(R.id.top)
    View top;
    @BindView(R.id.ll_orderdetail_stauts_tv)
    TextView llOrderdetailStautsTv;
    @BindView(R.id.ll_orderdetail_stauts_img)
    ImageView llOrderdetailStautsImg;
    @BindView(R.id.ll_orderdetail_address_name)
    TextView llOrderdetailAddressName;
    @BindView(R.id.ll_orderdetail_address_phone)
    TextView llOrderdetailAddressPhone;
    @BindView(R.id.ll_orderdetail_address_address)
    TextView llOrderdetailAddressAddress;
    @BindView(R.id.ll_orderdetail_goods_storename)
    TextView llOrderdetailGoodsStorename;
    @BindView(R.id.ll_orderdetail_goods_stutas)
    TextView llOrderdetailGoodsStutas;
    @BindView(R.id.ll_orderdetail_goods_img)
    ImageView llOrderdetailGoodsImg;
    @BindView(R.id.ll_orderdetail_goods_title)
    TextView llOrderdetailGoodsTitle;
    @BindView(R.id.ll_orderdetail_goods_price)
    TextView llOrderdetailGoodsPrice;
    @BindView(R.id.ll_orderdetail_goods_num)
    TextView llOrderdetailGoodsNum;
    @BindView(R.id.ll_orderdetail_goods_spec)
    TextView llOrderdetailGoodsSpec;
    @BindView(R.id.ll_orderdetail_goods_teamdetail)
    TextView llOrderdetailGoodsTeamdetail;
    @BindView(R.id.ll_orderdetail_goods_yunfree)
    TextView llOrderdetailGoodsYunfree;
    @BindView(R.id.ll_orderdetail_goods_coupon_store_tv)
    TextView llOrderdetailGoodsCouponStoreTv;
    @BindView(R.id.ll_orderdetail_goods_coupon_store_ll)
    LinearLayout llOrderdetailGoodsCouponStoreLl;
    @BindView(R.id.ll_orderdetail_goods_coupon_general_tv)
    TextView llOrderdetailGoodsCouponGeneralTv;
    @BindView(R.id.ll_orderdetail_goods_coupon_general_ll)
    LinearLayout llOrderdetailGoodsCouponGeneralLl;
    @BindView(R.id.ll_orderdetail_goods_coupon_leader_tv)
    TextView llOrderdetailGoodsCouponLeaderTv;
    @BindView(R.id.ll_orderdetail_goods_coupon_leader_ll)
    LinearLayout llOrderdetailGoodsCouponLeaderLl;
    @BindView(R.id.ll_orderdetail_goods_price_total)
    TextView llOrderdetailGoodsPriceTotal;
    @BindView(R.id.ll_orderdetail_goods_price_coupon)
    TextView llOrderdetailGoodsPriceCoupon;
    @BindView(R.id.ll_orderdetail_goods_price_pay)
    TextView llOrderdetailGoodsPricePay;
    @BindView(R.id.ll_orderdetail_goods_order_sn)
    TextView llOrderdetailGoodsOrderSn;
    @BindView(R.id.ll_orderdetail_goods_paystyle)
    TextView llOrderdetailGoodsPaystyle;
    @BindView(R.id.ll_orderdetail_goods_paytime)
    TextView llOrderdetailGoodsPaytime;
    @BindView(R.id.detail_like_grid)
    MyGridView detailLikeGrid;
    @BindView(R.id.scroll)
    ScrollView scroll;
    @BindView(R.id.click_resetnetwork)
    LinearLayout clickResetnetwork;
    @BindView(R.id.progress)
    RelativeLayout progress;
    @BindView(R.id.no_data)
    RelativeLayout noData;
    @BindView(R.id.no_data_tv)
    TextView noDataTv;
    @BindView(R.id.pay_style_list)
    NestFullListView payStyleList;
    @BindView(R.id.pay_style_ll)
    LinearLayout payStyleLl;
    @BindView(R.id.ll_orderdetail_bottom_receive_ll)
    LinearLayout llOrderdetailBottomReceiveLl;
    @BindView(R.id.ll_orderdetail_bottom_pay_ll)
    LinearLayout llOrderdetailBottomPayLl;
    @BindView(R.id.ll_orderdetail_bottom_rate_ll)
    LinearLayout llOrderdetailBottomRateLl;
    @BindView(R.id.ll_orderdetail_bottom_rate_applyrefound)
    TextView ll_orderdetail_bottom_rate_applyrefound;
    @BindView(R.id.ll_orderdetail_bottom_detele_ll)
    LinearLayout llOrderdetailBottomDeteleLl;
    @BindView(R.id.ll_orderdetail_bottom_lottery_ll)
    LinearLayout llOrderdetailBottomLotteryLl;
    @BindView(R.id.progress_loading)
    FrameLayout progressLoading;
    @BindView(R.id.ll_orderdetail_bottom_receive_express)
    TextView llOrderdetailBottomReceiveExpress;
    @BindView(R.id.ll_orderdetail_bottom_receive_sure)
    TextView llOrderdetailBottomReceiveSure;
    @BindView(R.id.ll_orderdetail_bottom_pay_canel)
    TextView llOrderdetailBottomPayCanel;
    @BindView(R.id.ll_orderdetail_bottom_pay_topay)
    TextView llOrderdetailBottomPayTopay;
    @BindView(R.id.ll_orderdetail_bottom_rate_torate)
    TextView llOrderdetailBottomRateTorate;
    @BindView(R.id.ll_orderdetail_bottom_detele_todetele)
    TextView llOrderdetailBottomDeteleTodetele;
    @BindView(R.id.ll_orderdetail_bottom_lottery_detail)
    TextView llOrderdetailBottomLotteryDetail;

    private FragmentActivity mcontext;
    private View view;
    private LayoutInflater inflater;
    private ArrayList<MainList.MainListdata.Mainlistdata> listdata = new ArrayList<>();
    private boolean networkConnected;
    private GridDetaillikeAdapt adapter;
    private static final String ARG_PARAM1 = "param1";
    private String order_sn;
    private int goods_id;
    private int order_id;
    private String bid;
    private String kf_online;
    private String goods_img_src;
    private String goods_spec;
    private String goods_buy_num;
    private int common_id;
    private ArrayList<MainTabData> mSortListdata = new ArrayList<>();
    private MainMsg mainMsg;
    private int status_id;

    public Fragment_Mine_Detail() {

    }

    public static Fragment_Mine_Detail newInstance(String need_id) {
        Fragment_Mine_Detail fragment = new Fragment_Mine_Detail();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, need_id);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            order_sn = getArguments().getString(ARG_PARAM1);
        }
    }

    @Override
    protected void initPrepare() {
        initUI();
    }

    @Override
    protected void onInvisible() {

    }

    @Override
    protected void initData() {
        GetDataOrder(order_sn);
        GetDataListData("&typeid=1");
    }

    @Override
    protected View initView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.inflater = inflater;
        view = inflater.inflate(R.layout.fragment_mine_order_detail, container, false);
        mcontext = getActivity();
        ButterKnife.bind(this, view);
        return view;
    }

    private int pospay = 0;
    private String pay_id = "42";

    private void initUI() {
        scroll.smoothScrollTo(0, 0);
        top.setFocusable(true);
        top.setFocusableInTouchMode(true);
        top.requestFocus();
        adapter = new GridDetaillikeAdapt(mcontext, listdata);
        detailLikeGrid.setAdapter(adapter);
        detailLikeGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ObjectUtils.ToDetailActivity(mcontext, 1, listdata.get(position).getId(), "");

            }
        });
//
//        mSortListdata.add(new MainTabData("微信(未开通)", "42", R.mipmap.support_pay_wx));
//        mSortListdata.add(new MainTabData("支付宝(未开通)", "", R.mipmap.support_pay_ali));
//        mSortListdata.add(new MainTabData("银联(未开通)", "", R.mipmap.support_pay_yl));
        payStyleList.setAdapter(new NestFullListViewAdapter<MainTabData>(R.layout.item_pay, mSortListdata) {
            @Override
            public void onBind(int position, MainTabData testBean, NestFullViewHolder holder) {
                holder.setText(R.id.pay_name, testBean.getName());
                //  holder.setImageResource(R.id.pay_logo, testBean.getThumb());

                if (pospay == position) {//最后选择的位置
                    holder.setChecked(R.id.item_list_mine_pay_check, true);
                } else {
                    holder.setChecked(R.id.item_list_mine_pay_check, false);
                }

            }
        });

        payStyleList.setOnItemClickListener(new NestFullListView.OnItemClickListener() {
            @Override
            public void onItemClick(NestFullListView nestFullListView, View view, int position) {
                pospay = position;
                nestFullListView.updateUI();
                pay_id = mSortListdata.get(position).getId();
            }
        });
    }


    @OnClick({R.id.ll_orderdetail_goods_img, R.id.ll_orderdetail_goods_contact, R.id.ll_orderdetail_goods_call,
            R.id.ll_orderdetail_bottom_receive_express, R.id.ll_orderdetail_bottom_receive_sure,
            R.id.ll_orderdetail_bottom_pay_canel, R.id.ll_orderdetail_bottom_pay_topay, R.id.ll_orderdetail_bottom_rate_torate,
            R.id.ll_orderdetail_bottom_rate_applyrefound, R.id.ll_orderdetail_bottom_detele_todetele, R.id.ll_orderdetail_bottom_lottery_detail
            , R.id.ll_orderdetail_goods_teamdetail})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ll_orderdetail_bottom_rate_applyrefound:
                break;
            case R.id.ll_orderdetail_bottom_detele_todetele:
                mainMsg = new MainMsg(mcontext);
                mainMsg.show(mcontext.getWindow().getDecorView(), 0, "是否删除订单？");
                mainMsg.setOnSetSureClickListener(new MainMsg.OnSetSureClickListener() {
                    @Override
                    public void onSure() {
                        String address = ConstantsUrl.domain + ConstantsUrl.MEMBERORDERDETELE + "?id=" + order_id;
                        setCancel(address, llOrderdetailBottomDeteleTodetele, null);
                        mainMsg.close();
                    }
                });
                break;
            case R.id.ll_orderdetail_bottom_lottery_detail:
                break;
            case R.id.ll_orderdetail_bottom_receive_express:
                Intent intent_express = new Intent(mcontext, BaseObject.class);
                intent_express.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "物流详情");
                intent_express.putExtra("need_id", order_sn);
                startActivity(intent_express);

                break;
            case R.id.ll_orderdetail_bottom_receive_sure:
                mainMsg = new MainMsg(mcontext);
                mainMsg.show(mcontext.getWindow().getDecorView(), 0, "是否确认收到货物？");
                mainMsg.setOnSetSureClickListener(new MainMsg.OnSetSureClickListener() {
                    @Override
                    public void onSure() {
                        String address = ConstantsUrl.domain + ConstantsUrl.MEMBERORDERQUERENSHOUHUO + "?id=" + order_id;
                        setCancel(address, llOrderdetailBottomReceiveSure, llOrderdetailBottomRateLl);
                        mainMsg.close();
                    }
                });
                break;
            case R.id.ll_orderdetail_bottom_pay_canel:
                mainMsg = new MainMsg(mcontext);
                mainMsg.show(mcontext.getWindow().getDecorView(), 0, "是否取消订单？");
                mainMsg.setOnSetSureClickListener(new MainMsg.OnSetSureClickListener() {
                    @Override
                    public void onSure() {
                        String address = ConstantsUrl.domain + ConstantsUrl.MEMBERORDERCANCEL + "?id=" + order_id;
                        setCancel(address, llOrderdetailBottomPayLl, llOrderdetailBottomDeteleLl);
                        mainMsg.close();
                    }
                });
                break;
            case R.id.ll_orderdetail_bottom_pay_topay:
                ObjectUtils.toast(mcontext, "抱歉，支付方式还未启用");
                break;
            case R.id.ll_orderdetail_goods_img:
                ObjectUtils.ToDetailActivity(mcontext, 1, "" + goods_id, "");
                break;
            case R.id.ll_orderdetail_goods_teamdetail:
                Intent intent_tuan = new Intent(mcontext, BaseObject.class);
                intent_tuan.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "团详情");
                intent_tuan.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_NEED_ID, common_id + "");
                mcontext.startActivity(intent_tuan);
                break;
            case R.id.ll_orderdetail_goods_contact:
                Intent intents = new Intent(mcontext, BaseObject.class);
                intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "客服");
                if (TextUtils.isEmpty(kf_online)) {
                    if (bid != null && !bid.equals("")) {
                        intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL, ConstantsUrl.baseDomain + "chat?good_id=" + goods_id + "&bid=" + bid);
                    } else {
                        intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL, ConstantsUrl.baseDomain + "chat?good_id=" + goods_id);
                    }
                } else {
                    intents.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_WEB_URL, kf_online);
                }
                startActivity(intents);
                break;
            case R.id.ll_orderdetail_goods_call:
                //   ObjectUtils.toast(mcontext, "拨打电话");
                break;
            case R.id.ll_orderdetail_bottom_rate_torate:
                Intent intent = new Intent(mcontext, BaseObject.class);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_TITLE, "评价");
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_RATE_GOOD_ID, goods_id + "");
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_RATE_ID, order_id + "");
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_RATE_BUY_NUM, goods_buy_num + "");
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_RATE_GOODS_SPEC, goods_spec);
                intent.putExtra(ConstantsUrl.INTENT_KEY.MAIN_GROUP_OBJEXT_SORT_RATE_THUMB, goods_img_src);
                startActivity(intent);
                break;
        }
    }

    //网络数据
    private void GetDataOrder(String id) {
        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        if (networkConnected) {
            String address = ConstantsUrl.domain + ConstantsUrl.MEMBERORDERDETAIL + "?order_sn=" + id;
            MyLog.e("order_sn", id);
            MyLog.e("地址", address);
            String getid = LoginState.getInstance().getid(mcontext);
            String getpd = LoginState.getInstance().getpd(mcontext);
            HashMap<String, String> header = new HashMap<>();
            header.put("UID", getid);
            header.put("UPSW", getpd);
            HttpUtils.get(address, header, null, new OrderDetailDataCallback() {

                @Override
                public void onError(Call call, Exception e, int id) {
                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 2);
                }

                @Override
                public void onResponse(OrderDetailData response, int id) {
                    if (response == null) {
                        ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
                        return;
                    }
                    OrderDetailData.DataBean data = response.getData();
                    if (response.getCode() == 0 && data != null) {
                        String status_common = data.getStatus_common();
                        kf_online = response.getKf_online();
                        bid = data.getBid();
                        switch (status_common) {
                            case "0":
                                //直接购买 没有团长优惠
                                llOrderdetailGoodsCouponLeaderLl.setVisibility(View.GONE);
                                break;
                            case "1":
                                llOrderdetailStautsTv.setText("拼团还未成功，\n邀请小伙伴们都来拼团吧");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                break;
                            case "2":
                                llOrderdetailStautsTv.setText("未成团,退款成功");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang_no);
                                break;
                            case "10":
                                llOrderdetailStautsTv.setText("拼团成功等待发货");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang_yes);
                                break;
                            default:
                                break;
                        }
                        status_id = data.getStatus_id();
                        switch (status_id) {
                            case 100:
                                //待付款
                                llOrderdetailStautsTv.setText("等待买家付款");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                payStyleLl.setVisibility(View.VISIBLE);
                                llOrderdetailBottomPayLl.setVisibility(View.VISIBLE);
                                break;
                            case 101:
                                //待发货
                                llOrderdetailStautsTv.setText("等待卖家发货");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                break;
                            case 102:
                                //待收货
                                llOrderdetailStautsTv.setText("等待买家收货");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                llOrderdetailBottomReceiveLl.setVisibility(View.VISIBLE);
                                break;
                            case 110:
                                //待评价
                                llOrderdetailStautsTv.setText("等待买家评价");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                llOrderdetailBottomRateLl.setVisibility(View.VISIBLE);
                                if (data.getIs_rate().equals("0")) {
                                    llOrderdetailBottomRateLl.setVisibility(View.VISIBLE);
                                } else {
                                    llOrderdetailBottomRateLl.setVisibility(View.GONE);
                                }
                                //无是否退款判断字段隐藏
                                ll_orderdetail_bottom_rate_applyrefound.setVisibility(View.GONE);
                                break;
                            case 111:
                                //已取消
                                llOrderdetailStautsTv.setText("订单已取消");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                llOrderdetailBottomDeteleLl.setVisibility(View.VISIBLE);
                                break;
                            case 112:
                                //退款中
                                llOrderdetailStautsTv.setText("等待处理退款");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                break;
                            case 113:
                                //退款成功
//                                llOrderdetailBottomDeteleLl.setVisibility(View.VISIBLE);
                                llOrderdetailStautsTv.setText("退款已成功");
                                llOrderdetailStautsImg.setImageResource(R.mipmap.dingdang);
                                break;
                            default:
//                                llOrderdetailBottomDeteleLl.setVisibility(View.VISIBLE);
                                break;
                        }

                        goods_id = data.getGoods_id();
                        order_id = data.getOrder_id();
                        llOrderdetailAddressName.setText(data.getName());
                        llOrderdetailAddressPhone.setText(data.getMobile());
                        llOrderdetailAddressAddress.setText(data.getArea() + data.getAddress());
                        llOrderdetailGoodsStutas.setText(data.getStatus_name());
                        llOrderdetailGoodsTitle.setText(data.getGoods_name());
                        llOrderdetailGoodsPrice.setText("￥" + data.getGoods_sell_price());
                        goods_buy_num = data.getGoods_buy_num();
                        llOrderdetailGoodsNum.setText("x" + goods_buy_num);
                        goods_img_src = data.getGoods_img_src();
                        goods_spec = data.getGoods_spec();
                        llOrderdetailGoodsSpec.setText(goods_spec);
                        ObjectUtils.photo(mcontext, goods_img_src, llOrderdetailGoodsImg);

                        common_id = Integer.parseInt(data.getCommon_id());
                        if (common_id > 0) {
                            llOrderdetailGoodsTeamdetail.setVisibility(View.VISIBLE);
                        } else {
                            llOrderdetailGoodsTeamdetail.setVisibility(View.GONE);
                        }
                        llOrderdetailGoodsPricePay.setText("￥" + data.getOrder_amount());
                        llOrderdetailGoodsPriceTotal.setText("￥" + data.getTotal_price());
                        llOrderdetailGoodsPriceCoupon.setText("￥" + data.getPreferential_price());
                        llOrderdetailGoodsOrderSn.setText(data.getOrder_sn());
                        llOrderdetailGoodsPaystyle.setText(data.getPay_name());
                        llOrderdetailGoodsPaytime.setText(data.getC_time());

                        //优惠通用
                        if (data.getAmount() == 0) {
                            llOrderdetailGoodsCouponGeneralLl.setVisibility(View.GONE);
                        } else {
                            llOrderdetailGoodsCouponGeneralLl.setVisibility(View.VISIBLE);
                            llOrderdetailGoodsCouponGeneralTv.setText("-￥" + data.getAmount());
                        }
                        //优惠团长
                        if (data.getDiscount_amount() == 0) {
                            llOrderdetailGoodsCouponLeaderLl.setVisibility(View.GONE);
                        } else {
                            llOrderdetailGoodsCouponLeaderLl.setVisibility(View.VISIBLE);
                            llOrderdetailGoodsCouponLeaderTv.setText("-￥" + data.getDiscount_amount());
                        }

                        //无店铺优惠券字段
                        llOrderdetailGoodsCouponStoreLl.setVisibility(View.GONE);
                        ObjectUtils.GetDataNet(clickResetnetwork, progress, 1);
                    } else {
                        noData.setVisibility(View.VISIBLE);
                        noDataTv.setText(response.getMsg());
                        noDataTv.setVisibility(View.VISIBLE);
                    }
                }
            });
        } else {
            ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
            ObjectUtils.toast(mcontext, "网络连接出现异常");
        }
    }


    //获取列表数据
    private void GetDataListData(String type) {
        String address = ConstantsUrl.domain + ConstantsUrl.MAIN_LISTDATA + "?size=" + 8 + type;
        networkConnected = ObjectUtils.isNetworkConnected(mcontext);
        if (networkConnected) {
            HttpUtils.get(address, null, new MainListCallback() {

                @Override
                public void onError(Call call, Exception e, int id) {
                }

                @Override
                public void onResponse(MainList response, int id) {
                    if (response == null) {
                        ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
                        return;
                    }
                    listdata.clear();
                    MainList.MainListdata data = response.getData();
                    if (data != null && ObjectUtils.listHasData(data.getList())) {
                        listdata.addAll(data.getList());
                        adapter.notifyDataSetChanged();
                    }
                }
            });
        }
    }

    @OnClick(R.id.click_resetnetwork_refresh)
    public void onClick() {
        ObjectUtils.GetDataNet(clickResetnetwork, progress, 3);
        GetDataOrder(order_sn);
        GetDataListData("&typeid=1");
    }

    private void setCancel(String url, final View view1, final LinearLayout view2) {
        progressLoading.setVisibility(View.VISIBLE);
        String getid = LoginState.getInstance().getid(mcontext);
        String getpd = LoginState.getInstance().getpd(mcontext);
        HashMap<String, String> header = new HashMap<>();
        header.put("UID", getid);
        header.put("UPSW", getpd);
        HttpUtils.get(url, header, null, new dataCallback() {

            @Override
            public void onError(Call call, Exception e, int id) {
                progressLoading.setVisibility(View.GONE);
            }

            @Override
            public void onResponse(data response, int id) {
                progressLoading.setVisibility(View.GONE);
                if (response == null) {
                    ObjectUtils.GetDataNet(clickResetnetwork, progress, 4);
                    return;
                }
                ObjectUtils.toast(mcontext, response.getMsg());
                if (response.getCode() == 0) {
                    if (status_id == 100) {
                        payStyleLl.setVisibility(View.GONE);
                    }
                    view1.setVisibility(View.GONE);
                    if (view2 != null) {
                        view2.setVisibility(View.VISIBLE);
                    }
                }
            }
        });
    }
}
